import { ref } from 'vue'
import { defineStore } from 'pinia'

export type Direction = 'rtl' | 'ltr'

export const useReadSettingStore = defineStore('readSetting', () => {
  const imgGap = ref(true)
  const offset = ref(2)
  const setImgGap = (bool: boolean) => (imgGap.value = bool)
  const setOffset = (num: number) => (offset.value = num)

  const direction = ref<Direction>('rtl')
  const setDirection = (val: Direction) => direction.value = val

  return { imgGap, setImgGap, offset, setOffset, direction, setDirection }
}, {
  persist: true // 持久化
})
